﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ControlAccessUser.Presenter;

namespace ControlAccessUser.Presentation
{
    /// <summary>
    /// Lógica de interacción para Welcom.xaml
    /// </summary>
    public partial class Welcom : Window,IPrincipalView
    {
        PresenterPrincipal pPrincipal;
        public Welcom(Model.User User)
        {
            InitializeComponent();
            pPrincipal = new PresenterPrincipal(this);
            UserLogin = User;
            lblWelCome.Content = "Welcome " + User.UserName;
        }

        #region
        public DateTime DateTimeLogin
        {
            get;
            set;
        }
        public DateTime DateTimeLogout
        {
            get;
            set;
        }
        public Model.User UserLogin
        {
            get;
            set;
        }
        public Model.Login Login
        {
            get;
            set;
        }
        #endregion

        private void btnLogout_Click(object sender, RoutedEventArgs e)
        {
            pPrincipal.Logout();
        }

        public void Logout()
        {
            this.Close();
        }

        private void btnNewUser_Click(object sender, RoutedEventArgs e)
        {
            pPrincipal.RegisterUser();
        }

        public void GoRegisterUser()
        {
            (new RegisterUser()).ShowDialog();
            Clear();
        }

        private void Clear()
        {
            
        }

        public bool UserReallyGoOut
        {
            get
            {
                if (MessageBox.Show("Desea Finalizar Sesion??", "Confirmacion", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            set
            {
                //throw new NotImplementedException();
            }
        }
        
        private void btnSalir(object sender, RoutedEventArgs e)
        {
            Logout();
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            pPrincipal.GoSearchUser(UserLogin);
        }


        public void GoSearchUser(Model.User User)
        {
            (new SearchUser(User)).ShowDialog();
        }
    }

}
